// Problem 19: Counting Sundays
// 1 Jan 1900 was a Monday.
// How many Sundays fell on the first of the month during the twentieth century (1 Jan 1901 to 31 Dec 2000)?

package main

import (
	"fmt"
)

func p019() int {
	count, d := 0, 1
	for y := 1901; y <= 2000; y++ {
		for m := 1; m <= 12; m++ {
			switch m {
			case 1, 3, 5, 7, 8, 10, 12:
				d += 31
			case 4, 6, 9, 11:
				d += 30
			case 2:
				if y%4 == 0 && y%100 != 0 || y%400 == 0 {
					d += 29
				} else {
					d += 28
				}
			}
			//1901.01.01 was a Tuesday.
			if d%7 == 5 {
				count++
			}
		}
	}
	fmt.Println("Problem 019:", count)
	return count
}
